# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=nbformat
pkgbase=mingw-w64-python-jupyter-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-jupyter-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-jupyter-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-jupyter-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-jupyter-${_realname}")
pkgver=5.7.3
pkgrel=1
pkgdesc="The base implementation of the Jupyter Notebook format and Python APIs for working with notebooks (mingw-w64)"
url="https://jupyter.org"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
license=('BSD')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-fastjsonschema
    ${MINGW_PACKAGE_PREFIX}-python-jsonschema
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_core
    ${MINGW_PACKAGE_PREFIX}-python-traitlets
)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-build
    ${MINGW_PACKAGE_PREFIX}-python-installer
    ${MINGW_PACKAGE_PREFIX}-python-hatchling
    ${MINGW_PACKAGE_PREFIX}-python-hatch-nodejs-version
)
source=("https://pypi.io/packages/source/${_realname:0:1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('4b021fca24d3a747bf4e626694033d792d594705829e5e35b14ee3369f9f6477')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING.md "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
